from telnetlib import DO

import numpy as np
from manimlib import *
from numpy import flip, insert
import math

LV, QL, QH, JH = '#75cfb8', '#bbdfc8', '#f0e5d8', '#ffc478'


class p1(Scene):
    def construct(self):
        # self.camera.frame.save_state()
        # self.add(NumberPlane())
        # self.camera.frame.rotate(13*DEGREES,about_point=[0.0, 0.0, 1.0])
        ab=Line(DOWN*3,UP*3).shift(LEFT*3+DOWN*0.5)
        a,b=ab.get_bottom(),ab.get_top()
        ad_length=6*np.tan(40*DEGREES)
        d=a+RIGHT*ad_length
        ad,bd=Line(a,d),Line(b,d)
        c=a+RIGHT*6
        c_=Dot(c).rotate(PI,[np.cos(40*DEGREES),np.sin(40*DEGREES),0],about_point=np.array(b)/2+np.array(d)/2).get_center()
        c_b,c_d=Line(c_,b),Line(c_,d)
        angle_b = Angle(Line(b, a), Line(b, d))
        angle_d=Angle(Line(d, c_), Line(d, b), radius=2)
        angle_c_=Angle(Line(c_, b), Line(c_, d))
        self.add(ab,ad,bd,c_b,c_d,angle_c_,angle_d,angle_b,
                 Angle(ad,ab,elbow=True),
                 Tex('6').next_to(ab,LEFT),
                 Tex('A').next_to(a,DL),
                 Tex('B').next_to(b,LEFT),
                 Tex('C').next_to(c_,UP),
                 Tex('D').next_to(d,DOWN),
                 #
                 Tex(r'40^\circ').next_to(angle_b,DOWN).shift((RIGHT*0.08)),
                 Tex(r'5^\circ').next_to(angle_d,UR),
                 Tex(r'45^\circ').next_to(angle_c_,DOWN).shift(RIGHT*0.05)
                 )
        self.wait()

class p2(Scene):
    def construct(self):
        # self.camera.frame.save_state()
        # self.add(NumberPlane())
        # self.camera.frame.rotate(13*DEGREES,about_point=[0.0, 0.0, 1.0])
        ab=Line(DOWN*3,UP*3).shift(LEFT*3+DOWN*0.5)
        a,b=ab.get_bottom(),ab.get_top()
        ad_length=6*np.tan(40*DEGREES)
        d=a+RIGHT*ad_length
        ad,bd=Line(a,d),Line(b,d)
        c=a+RIGHT*6
        c_=Dot(c).rotate(PI,[np.cos(40*DEGREES),np.sin(40*DEGREES),0],about_point=np.array(b)/2+np.array(d)/2).get_center()
        cb,ca=Line(c,b),Line(c,a)
        angle_b = Angle(Line(b, a), Line(b, d))
        angle_d=Angle(Line(b, d), Line(b, c), radius=2)
        angle_c=Angle(Line(c, b), Line(c, a))
        self.add(ab,ad,bd,angle_c,angle_d,angle_b,cb,ca,
                 Angle(ad,ab,elbow=True),
                 Tex('6').next_to(ab,LEFT),
                 Tex('A').next_to(a,DL),
                 Tex('B').next_to(b,LEFT),
                 Tex('C').next_to(c,DR),
                 Tex('D').next_to(d,DOWN),
                 #
                 Tex(r'40^\circ').next_to(angle_b,DOWN).shift((RIGHT*0.08)),
                 Tex(r'5^\circ').next_to(angle_d,UR),
                 Tex(r'45^\circ').next_to(angle_c,UL).shift(DOWN*0.2)
                 )
        self.wait()
